package com.hy.item.mapper;

import com.hy.item.pojo.Brand;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;

public interface BrandMapper extends Mapper<Brand> {
    /**
     * 新增中间表
     */
    //添加sql语句
    @Insert("INSERT INTO tb_category_brand (category_id,brand_id) values (#{cid},#{bid})")
    //自定义一个新增的方法,传入需要新增的字段的参数
    int insertCategoryBrand(@Param("cid") Long cid,@Param("bid") Long bid);
    /**
     * 通过分类id查询品牌信息
     */
    @Select("SELECT b.* FROM tb_brand b INNER JOIN tb_category_brand cb " +
            "ON b.id=cb.brand_id where cb.category_id=#{cid}")
    List<Brand> queryBrandByCid(@Param("cid") Long cid);

}
